<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="viewport" id="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no"/>
<link href="./css/reset.css" rel="stylesheet" type="text/css">
<link href="./css/receiving-adress.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
</head>
<body>
<div class="near-box">
	<div class="header">
		<a href="javascript:history.back()" class="left"></a>
		<p class="headerText">收货地址</p>
	</div>
	<div class="bigbox">
	</div>
</div>
<script type="text/javascript">
$(function(){
	$.post("../../../tszs/txr/addressselect.do",function(data){
		if(data.type==1){
			var html="";
			var subhmtl="";
			for (var i = 0; i < data.data.length; i++) {
		 if(data.data[i].uDouble==1){
			 html+="<div class=\"sh-adress-box1\">"+
		 	 "<a href=\"\" class=\"sh-adress-box2\">"+
	 	 	"<span class=\"sh-adress-text1\">"+data.data[i].uName+"</span>"+
	 	 	"<span class=\"sh-adress-text1 text-r\">"+data.data[i].uPhone+"</span>"+
	 	 	"<span class=\"sh-adress-text2\">"+data.data[i].uAddress+"</span>"+
	 	"</a>"+
	 	 "<div class=\"sh-adress-box3\">"+
	 	 	"<div id='"+data.data[i].uId+"' class=\"sh-adress-text3 img2\">设为默认地址</div>"+
	 	 	"<div class=\"sh-adress-text4\">删除</div>"+
	 	 "</div>"+
	 "</div>";
		 }else{
			 html+="<div class=\"sh-adress-box1\">"+
		 	 "<a href=\"\" class=\"sh-adress-box2\">"+
	 	 	"<span class=\"sh-adress-text1\">"+data.data[i].uName+"</span>"+
	 	 	"<span class=\"sh-adress-text1 text-r\">"+data.data[i].uPhone+"</span>"+
	 	 	"<span class=\"sh-adress-text2\">"+data.data[i].uAddress+"</span>"+
	 	"</a>"+
	 	 "<div class=\"sh-adress-box3\">"+
	 	 	"<div id='"+data.data[i].uId+"' class=\"sh-adress-text3\">设为默认地址</div>"+
	 	 	"<div class=\"sh-adress-text4\">删除</div>"+
	 	 "</div>"+
	 "</div>";
		 }
				 subhmtl=" <a href=\"./receiving-adress.jsp\" class=\"set-text1\">添加新地址</a>"+
				 "<div class='delete-layer-bg' style='display: none;'></div>"+
				 "<div class=\"delete-layer\" style=\"display: none;\">"+
			        "<div class=\"active-a2\">确认后地址将被删除！</div>"+
			         "<div class=\"active-a3\">"+
			        	"<span class=\"other2 other1\">取消</span>"+
			        	"<span class=\"delete\" id='"+data.data[i].uId+"'>确定</span>"+
			        	"<div class=\"active-a3-x1\"></div>"+
			         "</div>"+
				 "</div>";
			}
			
			 var allhmtl=html+subhmtl;
			$(".bigbox").html(allhmtl);
		}else{
			$(".bigbox").html("<a href=\"./receiving-adress.jsp\" class=\"set-text1\">添加新地址</a><br>");
		}
	},"json")
})
</script>
<script type="text/javascript">
	var that;
	$(".bigbox").on("click",".sh-adress-text3",function () {
		 $(this).toggleClass("img2");
		 $(this).parent(".sh-adress-box3").parent(".sh-adress-box1").siblings(".sh-adress-box1")
		 .find(".sh-adress-text3").removeClass("img2");
         var val=$(this).attr("id");
         $.post("../../../tszs/txr/addressupdate.do?UId="+val,function(data){
        	 if(data.type==1){
        		 window.parent.location.reload();
			 	window.history.go(-1);
        	 }
		 },"json")
	});
	$(".bigbox").on("click",".sh-adress-text4",function () {
		 $(".delete-layer-bg").show();
		 $(".delete-layer").show();
		 $("body").addClass("ovflowhide");
		 that = $(this);
		 var val=$(this).attr("id");
	});
	$(".delete-layer-bg").click(function () {
		 $(".delete-layer-bg").hide();
		 $(".delete-layer").hide();
		 $("body").removeClass("ovflowhide");
	});
	$(".bigbox").on("click",".other1",function () {
		 $(".delete-layer-bg").hide();
		 $(".delete-layer").hide();
		 $("body").removeClass("ovflowhide");
	});
	$(".bigbox").on("click",".delete",function () {
		 $(".delete-layer-bg").hide();
		 $(".delete-layer").hide();
		 $("body").removeClass("ovflowhide");
		 $(that).parent(".sh-adress-box3").parent(".sh-adress-box1").remove();
		 var val=$(this).attr("id");
		 $.post("../../../tszs/txr/addressdelete.do?UId="+val,function(data){
		 },"json")
	});
</script>
</body>
</html>